﻿/*
    Copyright (c) 2013 Global Mandoo SL

    Permission is hereby granted, free of charge, to any person obtaining a 
    copy of this software and associated documentation files (the "Software"), 
    to deal in the Software without restriction, including without limitation 
    the rights to use, copy, modify, merge, publish, distribute, sublicense, 
    and/or sell copies of the Software, and to permit persons to whom the Software 
    is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be 
    included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
    BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
    ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    
    @author Mandoo Team <help@mandoocms.com>
    @copyright  2012 Global Mandoo SL
    @version  Release: $Revision: 2532 $
    International Registered Trademark & Property of Global Mandoo SL
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
using System.Net;
using System.Net.Http;
using System.IO;
using System.Xml;
using Windows.Data.Xml.Dom;
using Windows.Security.Authentication.Web;

namespace Mandoo
{
    /// <summary>
    /// Helps to connect with Mandoo doAPI
    /// </summary>
    public class DoAPI
    {
        #region Fields

        /// <summary>
        /// Client ID
        /// </summary>
        private string _clientId = "";
        /// <summary>
        /// Client Secret
        /// </summary>
        private string _clientSecret = "";
        /// <summary>
        /// 
        /// </summary>
        private string _params = "";
        /// <summary>
        /// 
        /// </summary>
        private string _responseFormat = "xml";
        /// <summary>
        /// 
        /// </summary>
        private string _method = "";
        /// <summary>
        /// GET or POST, default is GET
        /// </summary>
        private string _httpMethod = "GET";
        /// <summary>
        /// 
        /// </summary>
        private string _version = "1";
        /// <summary>
        /// Url Api mandoocms
        /// </summary>
        private string _apiUrl = "http://api.mandoocms.com";
        /// <summary>
        /// 
        /// </summary>
        private bool _includeOutHeader = false;
        /// <summary>
        /// 
        /// </summary>
        private string _output = null;
        #endregion

        #region Properthies
        /// <summary>
        /// 
        /// </summary>
        public string Params
        {
            get
            {
                return this._params;
            }
            set
            {
                this._params = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ApiUrl
        {
            get
            {
                return this._apiUrl;
            }
            set
            {
                this._apiUrl = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ResponseFormat
        {
            get
            {
                return this._responseFormat;
            }
            set
            {
                this._responseFormat = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public string Method
        {
            get
            {
                return this._method;
            }
            set
            {
                this._method = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public string Output
        {
            get
            {
                return this._output;
            }
            set
            {
                this._output = value;
            }
        }
        /// <summary>
        /// GET or POST, default is GET
        /// </summary>
        public string HttpMethod
        {
            get
            {
                return this._httpMethod;
            }
            set
            {
                this._httpMethod = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public bool OutputHeader
        {
            get
            {
                return this._includeOutHeader;
            }
            set
            {
                this._includeOutHeader = value;
            }
        }
        #endregion

        #region Constructor

        /// <summary>
        /// Create a new instance of Mandoo doAPI for .Net
        /// To create you need one Mandoo Account and Client Api ID and Client Secret
        /// You can get this data from www.mandoocms.com
        /// </summary>
        /// <param name="clientId">Your Client ID</param>
        /// <param name="clientSecret">Your Client Secret</param>
        public DoAPI(string clientId, string clientSecret)
        {
            if (clientId == "" || clientSecret == "")
            {
                return;
            }
            this._clientId = clientId;
            this._clientSecret = clientSecret;
            this._apiUrl = this._apiUrl + "/v" + this._version + "/";
        }

        public DoAPI()
        {
            this._apiUrl = this._apiUrl + "/v" + this._version + "/";
        }

        public bool Login(string user, string password)
        {
            try
            {
                string parameters = "user=" + user;
                parameters += "&pass=" + password;
                this._method = "login";
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(this.Call_Mandoo_Api_V1(parameters));
                IXmlNode xmlNode = xmlDocument.SelectSingleNode("/nodes/node");
                this._clientId = xmlNode.SelectSingleNode("client_id").InnerText;
                this._clientSecret = xmlNode.SelectSingleNode("client_secret").InnerText;
                return true;
            }
            catch
            {
                return false;
            }

        }

        #endregion

        #region doMail

        /***************************************************************************/
        /*								doMail								 	   */
        /***************************************************************************/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public string doMail_Groups(int[] ids)
        {
            string parameters = "ids=0";

            if (ids != null && ids.Length > 0)
            {
                parameters = "ids=" + String.Join(";", ids);
            }
            this._method = "doMail_Groups";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public string doMail_Group_Subscribers(int[] ids)
        {
            string parameters = "ids=0";

            if (ids != null && ids.Length > 0)
            {
                parameters = "ids=" + String.Join(";", ids);
            }
            this._method = "doMail_Group_Subscribers";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Add a new group  
        /// </summary>
        /// <param name="title">Title of the new group</param>
        /// <returns></returns>
        public string doMail_AddGroup(string title)
        {
            string parameters = "title=";
            if (title != null && title != "")
            {
                parameters = "title=" + title;
            }
            this._method = "doMail_AddGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id">Group identifier to update</param>
        /// <param name="title"></param>
        /// <returns></returns>
        public string doMail_UpdateGroup(int id, string title)
        {
            string parameters = "title=";

            if (title != null && title != "")
            {
                parameters = "title=" + title;
            }
            if (id > 0)
            {
                parameters += "&id=" + id;
            }
            this._method = "doMail_UpdateGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete a group
        /// </summary>
        /// <param name="id">Group identifier to delete</param>
        /// <returns></returns>
        public string doMail_DeleteGroup(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id;
            }
            this._method = "doMail_DeleteGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Add a new subscriber
        /// </summary>
        /// <param name="email">Email contact for the new subscriber</param>
        /// <returns></returns>
        public string doMail_AddSubscriber(string email)
        {
            string parameters = "";

            if (email != null && email != "")
            {
                parameters = "email=" + email;
            }
            this._method = "doMail_AddSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Search a subscriber
        /// </summary>
        /// <param name="email">Email identifier for search the subscriber</param>
        /// <returns></returns>
        public string doMail_IsSubscriber(string email)
        {
            string parameters = "";

            if (email != null && email != "")
            {
                parameters = "email=" + email;
            }
            this._method = "doMail_IsSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get a subscriber 
        /// </summary>
        /// <param name="id">Id identifier</param>
        /// <param name="email">Email identifier</param>
        /// <returns>Returns an array with subscriber data</returns>
        public string doMail_GetSubscriber(int id, string email)
        {
            string parameters = "1=1";

            if (id > 0)
            {
                parameters += "&id=" + id.ToString();
            }
            if (email != null && email != "")
            {
                parameters += "&email=" + email;
            }
            this._method = "doMail_GetSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete subscriber 
        /// </summary>
        /// <param name="id">Subscriber identifier</param>
        /// <returns></returns>
        public string doMail_DeleteSubscriber(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            this._method = "doMail_DeleteSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete subscriber
        /// </summary>
        /// <param name="email">Email identifier subscriber</param>
        /// <returns></returns>
        public string doMail_DeleteSubscriberEmail(string email)
        {
            string parameters = "";

            if (email != null && email != "")
            {
                parameters = "email=" + email;
            }
            this._method = "doMail_DeleteSubscriberEmail";

            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="users"></param>
        /// <returns></returns>
        public string doMail_AddSubscriberToGroup(int id, string users)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            if (users != null && users != "")
            {
                parameters += "&users=" + users;
            }
            this._method = "doMail_AddSubscriberToGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="users"></param>
        /// <returns></returns>
        public string doMail_RemoveSubscriberToGroup(int id, string users)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            if (users != null && users != "")
            {
                parameters += "&users=" + users;
            }
            this._method = "doMail_RemoveSubscriberToGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="campaignId"></param>
        /// <param name="groups"></param>
        /// <param name="subject"></param>
        /// <param name="html"></param>
        /// <param name="plaintext"></param>
        /// <param name="publishOnRss"></param>
        /// <param name="googleAnalyticsId"></param>
        /// <returns></returns>
        public string doMail_SendNewsletter(string campaignId, string groups, string subject, string html, string plaintext, string publishOnRss, string googleAnalyticsId)
        {
            string parameters = "";

            if (campaignId != null && campaignId != "")
            {
                parameters = "campaignId=" + campaignId;
            }
            if (groups != null && groups != "")
            {
                parameters += "&groups=" + groups;
            }
            if (subject != null && subject != "")
            {
                parameters += "&subject=" + subject;
            }
            if (html != null && html != "")
            {
                parameters += "&html=" + html;
            }
            if (plaintext != null && plaintext != "")
            {
                parameters += "&plaintext=" + plaintext;
            }
            if (publishOnRss != null && publishOnRss != "")
            {
                parameters += "&publishOnRss=" + publishOnRss;
            }
            if (googleAnalyticsId != null)
            {
                parameters += "&googleAnalyticsId=" + googleAnalyticsId;
            }

            this._method = "doMail_SendNewsletter";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="campaignId"></param>
        /// <param name="subscriber"></param>
        /// <param name="subject"></param>
        /// <param name="html"></param>
        /// <param name="plaintext"></param>
        /// <param name="publishOnRss"></param>
        /// <param name="googleAnalyticsId"></param>
        /// <returns></returns>
        public string doMail_SendNewsletterToSubscriber(string campaignId, string subscriber, string subject, string html, string plaintext, string publishOnRss, string googleAnalyticsId)
        {
            string parameters = "";

            if (campaignId != null && campaignId != "")
            {
                parameters = "campaignId=" + campaignId;
            }
            if (subscriber != null && subscriber != "")
            {
                parameters += "&subscriber=" + subscriber;
            }
            if (subject != null && subject != "")
            {
                parameters += "&subject=" + subject;
            }
            if (html != null && html != "")
            {
                parameters += "&html=" + html;
            }
            if (plaintext != null && plaintext != "")
            {
                parameters += "&plaintext=" + plaintext;
            }
            if (publishOnRss != null && publishOnRss != "")
            {
                parameters += "&publishOnRss=" + publishOnRss;
            }
            if (googleAnalyticsId != null)
            {
                parameters += "&googleAnalyticsId=" + googleAnalyticsId;
            }

            this._method = "doMail_SendNewsletterToSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Add a new campaign
        /// </summary>
        /// <param name="name">Name of the new campaign</param>
        /// <returns></returns>
        public string doMail_AddCampaign(string name)
        {
            string parameters = "";

            if (name != null && name != "")
            {
                parameters = "name=" + name;
            }
            this._method = "doMail_AddCampaign";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete campaign
        /// </summary>
        /// <param name="id">Campaign identifier to delete</param>
        /// <returns></returns>
        public string doMail_DeleteCampaign(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            this._method = "doMail_DeleteCampaign";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get campaign using the identifier
        /// </summary>
        /// <param name="id">Campaign identifier</param>
        /// <returns>Returns an array of campaign data</returns>
        public string doMail_GetCampaign(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            this._method = "doMail_GetCampaign";
            return this.Call_Mandoo_Api_V1(parameters);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doMail_GetTemplate(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }

            this._method = "doMail_GetTemplate";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get the categories of templates
        /// </summary>
        /// <returns></returns>
        public string doMail_GetCategoryTemplates()
        {
            string parameters = "";
            this._method = "doMail_GetCategoryTemplates";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="category"></param>
        /// <param name="isPublished"></param>
        /// <param name="showAssigned"></param>
        /// <param name="showall"></param>
        /// <param name="initPagination"></param>
        /// <param name="limitPagination"></param>
        /// <returns></returns>
        public string doMail_GetTemplates(int category, bool isPublished, bool showAssigned, bool showall, int initPagination, int limitPagination)
        {
            string parameters = "category=";

            if (category > -1)
            {
                parameters += category;
            }
            parameters += "&isPublished=" + isPublished;

            if (showAssigned)
            {
                parameters += "&showAssigned=" + showAssigned;
            }
            if (showall)
            {
                parameters += "&showall=" + showall;
            }
            if (initPagination > -1)
            {
                parameters += "&initPagination=" + initPagination;
            }
            if (limitPagination > -1)
            {
                parameters += "&limitPagination=" + limitPagination;
            }
            this._method = "doMail_GetTemplates";
            return this.Call_Mandoo_Api_V1(parameters);
        }


        #endregion

        #region doForms

        /***************************************************************************/
        /*								doForms								 	   */
        /***************************************************************************/
        /// <summary>
        /// Gets the number of forms with your account id
        /// </summary>
        /// <returns>Returns an integer value with the number of forms</returns>
        public string doforms_GetNumForms()
        {
            string parameters = "";
            this._method = "doforms_GetNumForms";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doforms_GetNumReports()
        {
            string parameters = "";
            this._method = "doforms_GetNumReports";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get the latest reports from doForm 
        /// </summary>
        /// <param name="limit">Defines the number of reports to obtain</param>
        /// <returns></returns>
        string doforms_GetLastReports(int limit)
        {
            string parameters = "limit=" + limit.ToString();
            this._method = "doforms_GetLastReports";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get forms delimited by range
        /// </summary>
        /// <param name="init">Select range init</param>
        /// <param name="end">Select range end</param>
        /// <returns></returns>
        public string doforms_GetForms(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doforms_GetForms";
            return this.Call_Mandoo_Api_V1(parameters);
        }

        /// <summary>
        /// Get forms with Newsletters Subscribe
        /// </summary>
        /// <param name="init">Select range init</param>
        /// <param name="end">Select range end</param>
        /// <returns></returns>
        public string doforms_GetFormsWithNewsletterSubscribe(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doforms_GetFormsWithNewsletterSubscribe";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get a form with a specified id
        /// </summary>
        /// <param name="id">Form identifier</param>
        /// <returns></returns>
        string doforms_GetForm(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_GetForm";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Extract only the forms with a date field
        /// </summary>
        /// <param name="init">Down limit of row</param>
        /// <param name="end">Up limit of row</param>
        /// <returns></returns>
        string doforms_GetFormsWithDateField(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doforms_GetFormsWithDateField";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get form by Identifier 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_GetFieldsOfForm(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_GetFieldsOfForm";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get a form data
        /// </summary>
        /// <param name="id">Form identifier</param>
        /// <param name="field">Field to extract data</param>
        /// <returns></returns>
        string doforms_GetDataOfForm(int id, string field)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&field=" + field;
            this._method = "doforms_GetDataOfForm";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="accountid"></param>
        /// <param name="formid"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="userId"></param>
        /// <param name="content"></param>
        /// <param name="type"></param>
        /// <param name="url"></param>
        /// <param name="urlLogo"></param>
        /// <param name="urlMessage"></param>
        /// <param name="urlBack"></param>
        /// <param name="urlStyle"></param>
        /// <param name="messagedescription"></param>
        /// <param name="messageStyle"></param>
        /// <param name="emails"></param>
        /// <param name="followUp"></param>
        /// <param name="deleted"></param>
        /// <param name="style"></param>
        /// <param name="canRepeatData"></param>
        /// <param name="history"></param>
        /// <param name="sourceform"></param>
        /// <param name="urlok"></param>
        /// <param name="urlko"></param>
        /// <param name="confirmationTemplate"></param>
        /// <param name="active"></param>
        /// <param name="isdefault"></param>
        /// <returns></returns>
        string doForms_UpdateForm(int accountid, int formid, DateTime deleted, string name = "", string description = "", int userId = 0, string content = "", int type = -1, string url = "", string urlLogo = "", string urlMessage = "", string urlBack = "", string urlStyle = "", string messagedescription = "", string messageStyle = "", string emails = "", int followUp = 0, string style = "", bool canRepeatData = false, bool history = false, int sourceform = 0, string urlok = "", string urlko = "", int confirmationTemplate = 0, bool active = false, bool isdefault = false)
        {
            string parameters = "accountid=" + accountid.ToString();
            parameters += "&formid=" + formid.ToString();
            parameters += "&name=" + name;
            parameters += "&description=" + description;
            parameters += "&userId=" + userId;
            parameters += "&content=" + content;
            parameters += "&type=" + type;
            parameters += "&url=" + url;
            parameters += "&urlLogo=" + urlLogo;
            parameters += "&urlMessage=" + urlMessage;
            parameters += "&urlBack=" + urlBack;
            parameters += "&urlStyle=" + urlStyle;
            parameters += "&messagedescription=" + messagedescription;
            parameters += "&messageStyle=" + messageStyle;
            parameters += "&emails=" + emails;
            parameters += "&followUp=" + followUp;
            parameters += "&deleted=" + deleted;
            parameters += "&style=" + style;
            parameters += "&canRepeatData=" + canRepeatData;
            parameters += "&history=" + history;
            parameters += "&sourceform=" + sourceform;
            parameters += "&urlok=" + urlok;
            parameters += "&urlko=" + urlko;
            parameters += "&confirmationTemplate=" + confirmationTemplate;
            parameters += "&active=" + active;
            parameters += "&isdefault=" + isdefault;
            this._method = "doForms_UpdateForm";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="accountid"></param>
        /// <param name="formid"></param>
        /// <param name="count"></param>
        /// <param name="searchText"></param>
        /// <param name="rows"></param>
        /// <param name="filter"></param>
        /// <param name="order"></param>
        /// <param name="logicCondition"></param>
        /// <param name="up"></param>
        /// <param name="initDate"></param>
        /// <param name="endDate"></param>
        /// <param name="?"></param>
        /// <param name="initPagination"></param>
        /// <param name="limitPagination"></param>
        /// <returns></returns>
        string doForms_SearchReports(int accountid, int formid, int count, string searchText, string rows, string filter, string order, string logicCondition, int up, string initDate, string endDate, string rand, int initPagination, int limitPagination)
        {
            string parameters = "accountid=" + accountid.ToString();
            parameters += "&formid=" + formid.ToString();
            parameters += "&count=" + count.ToString();
            parameters += "&searchText=" + searchText;
            parameters += "&rows=" + rows;
            parameters += "&filter=" + filter;
            parameters += "&order=" + order;
            parameters += "&logicCondition=" + logicCondition;
            parameters += "&up=" + up.ToString();
            parameters += "&initDate=" + initDate;
            parameters += "&endDate=" + endDate;
            parameters += "&rand=" + rand;
            parameters += "&limitPagination=" + initPagination.ToString();
            this._method = "doForms_SearchReports";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        string doForms_GetSubmissionsPerMonth(int id, string month, string year)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&month=" + month;
            parameters += "&year=" + year;
            this._method = "doForms_GetSubmissionsPerMonth";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doForms_GetFormFields(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doForms_GetFormFields";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doForms_GetFormFieldsToImport(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doForms_GetFormFieldsToImport";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doForms_ClearData(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doForms_ClearData";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete form data
        /// </summary>
        /// <param name="id">Form data identifier</param>
        /// <returns></returns>
        string doforms_Form_Data_Delete(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_Form_Data_Delete";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        string doForms_DeleteFormDataSelected(int id, string op)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&op=" + op;
            this._method = "doForms_DeleteFormDataSelected";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        string doforms_Form_Delete(int id)
        {
            string parameters = "id=" + id;
            this._method = "doforms_Form_Delete";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="searchText"></param>
        /// <param name="rows"></param>
        /// <param name="filter"></param>
        /// <param name="order"></param>
        /// <param name="initDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        string doForms_DeleteFormView(int id, string searchText, string rows, string filter, string order, string initDate, string endDate)
        {
            string parameters = "id=" + id.ToString();
            parameters += "searchText=" + searchText;
            parameters += "rows=" + rows;
            parameters += "filter=" + filter;
            parameters += "order=" + order;
            parameters += "initDate=" + initDate;
            parameters += "endDate=" + endDate;
            this._method = "doForms_DeleteFormView";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get the categories of Form templates
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_FormTemplatesCategories(int id)
        {
            string parameters = "id=" + id;
            this._method = "doforms_FormTemplatesCategories";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get the Form templates of a category
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        string doforms_FormTemplatesbyCategory(int category)
        {
            string parameters = "category=" + category;
            this._method = "doforms_FormTemplatesbyCategory";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get the Form templates of a category
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doforms_GetFormTemplate(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_GetFormTemplate";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_Template_Enabled(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_Template_Enabled";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_Template_Disabled(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_Template_Disabled";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_Template_Publish(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_Template_Publish";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_Template_Delete(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_Template_Delete";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        string doforms_LoadStatisticsByHour(int id, string beginDate, string endDate, DateTime timezonevalue)
        {
            string parameters = "id=" + id.ToString();
            parameters += "beginDate=" + beginDate;
            parameters += "endDate=" + endDate;
            parameters += "timezonevalue=" + timezonevalue.ToString();
            this._method = "doforms_LoadStatisticsByHour";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Copy the form
        /// </summary>
        /// <param name="id">Form identifier</param>
        /// <returns></returns>
        public string doforms_Form_Copy(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_Form_Copy";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        string doForms_GetFormDataWithSubscribers(string ids)
        {
            string parameters = "ids=" + ids;
            this._method = "doforms_Form_Copy";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_MarkFormDataAsRead(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_MarkFormDataAsRead";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        string doforms_MarkFormDataAsUnRead(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doforms_MarkFormDataAsRead";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="encoded"></param>
        /// <param name="type"></param>
        /// <param name="url"></param>
        /// <param name="urlLogo"></param>
        /// <param name="urlMessage"></param>
        /// <param name="urlBack"></param>
        /// <param name="urlStyle"></param>
        /// <param name="emails"></param>
        /// <param name="followUp"></param>
        /// <param name="encodedGeneral"></param>
        /// <param name="canRepeatData"></param>
        /// <param name="urlok"></param>
        /// <param name="urlko"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        string doForms_Save(int id, string name, string description, string encoded, int type, string url, string urlLogo, string urlMessage, string urlBack, string urlStyle, string emails, int followUp, string encodedGeneral, bool canRepeatData, string urlok, string urlko, int template)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&name=" + name;
            parameters += "&description=" + description;
            parameters += "&encoded=" + encoded;
            parameters += "&type=" + type.ToString();
            parameters += "&url=" + url;
            parameters += "&urlLogo=" + urlLogo;
            parameters += "&urlMessage=" + urlMessage;
            parameters += "&urlBack=" + urlBack;
            parameters += "&urlStyle=" + urlStyle;
            parameters += "&emails=" + emails;
            parameters += "&followUp=" + followUp.ToString();
            parameters += "&encodedGeneral=" + encodedGeneral;
            parameters += "&canRepeatData=" + canRepeatData.ToString();
            parameters += "&urlok=" + urlok;
            parameters += "&urlko=" + urlko;
            parameters += "&template=" + template.ToString();
            this._method = "doForms_Save";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="encoded"></param>
        /// <param name="encodedGeneral"></param>
        /// <param name="style"></param>
        /// <returns></returns>
        string doForms_SaveTemplate(int id, string name, string encoded, string encodedGeneral, string style)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&name=" + name;
            parameters += "&encoded=" + encoded;
            parameters += "&encodedGeneral=" + encodedGeneral;
            parameters += "&style=" + style;
            this._method = "doForms_SaveTemplate";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public string doForms_GetFormsPublicId(int id)
        {
            string parameters = "";
            if (id > 0)
            {
                parameters = "id=" + id;
            }
            this._method = "doForms_GetFormsPublicId";
            return this.Call_Mandoo_Api_V1(parameters);
        }


        #endregion

        #region doDeals

        /***************************************************************************/
        /*								doDeals									   */
        /***************************************************************************/
        /// <summary>
        /// Create a new deal
        /// </summary>
        /// <param name="name"></param>
        /// <param name="url"></param>
        /// <param name="value"></param>
        /// <param name="realValue"></param>
        /// <param name="category"></param>
        /// <param name="finePrints"></param>
        /// <param name="highlights"></param>
        /// <param name="termsAndCondition"></param>
        /// <param name="payCaptureStatus"></param>
        /// <param name="sideDeal"></param>
        /// <param name="metaKeywords"></param>
        /// <param name="metaDescription"></param>
        /// <param name="mainDeal"></param>
        /// <param name="expiryDate"></param>
        /// <param name="isVideo"></param>
        /// <param name="embedCode"></param>
        /// <param name="maxDealPurchase"></param>
        /// <param name="instantDeal"></param>
        /// <param name="forceCouponClosed"></param>
        /// <param name="description"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="image"></param>
        /// <param name="slideimage"></param>
        /// <param name="slideimage2"></param>
        /// <param name="slideimage3"></param>
        /// <param name="status"></param>
        /// <param name="minUserLimit"></param>
        /// <param name="maxUserLimit"></param>
        /// <param name="person"></param>
        /// <param name="phoneNo"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public string doDeals_NewDeal(string name, string url, float value, int realValue, int category, string finePrints, string highlights, string termsAndCondition, int payCaptureStatus, int sideDeal, string metaKeywords, string metaDescription, int mainDeal, DateTime expiryDate, bool isVideo, string embedCode, int maxDealPurchase, int instantDeal, string forceCouponClosed, DateTime startDate, DateTime endDate, string description = null, string image = null, string slideimage = null, string slideimage2 = null, string slideimage3 = null, string status = null, int minUserLimit = 0, int maxUserLimit = 0, string person = null, string phoneNo = null, string address = null)
        {
            string parameters = "name=" + name;
            parameters += "&url=" + url;
            parameters += "&description=" + description;
            parameters += "&startDate=" + startDate;
            parameters += "&endDate=" + endDate;
            parameters += "&image=" + image;
            parameters += "&slideimage=" + slideimage;
            parameters += "&slideimage2=" + slideimage2;
            parameters += "&&slideimage3=" + slideimage3;
            parameters += "&value=" + value;
            parameters += "&status=" + status;
            parameters += "&minUserLimit=" + minUserLimit;
            parameters += "&maxUserLimit=" + maxUserLimit;
            parameters += "&realValue=" + realValue;
            parameters += "&category=" + category;
            parameters += "&person=" + person;
            parameters += "&phoneNo=" + phoneNo;
            parameters += "&address=" + address;
            parameters += "&finePrints=" + finePrints;
            parameters += "&highlights=" + highlights;
            parameters += "&termsAndCondition=" + termsAndCondition;
            parameters += "&payCaptureStatus=" + payCaptureStatus;
            parameters += "&sideDeal=" + sideDeal;
            parameters += "&metaKeywords=" + metaKeywords;
            parameters += "&metaDescription=" + metaDescription;
            parameters += "&mainDeal=" + mainDeal;
            parameters += "&expiryDate=" + expiryDate;
            parameters += "&isVideo=" + isVideo;
            parameters += "&embedCode=" + embedCode;
            parameters += "&maxDealPurchase=" + maxDealPurchase;
            parameters += "&instantDeal=" + instantDeal;
            parameters += "&forceCouponClosed=" + forceCouponClosed;

            parameters = "";
            this._method = "doDeals_NewDeal";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Update deal with especific identification
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="url"></param>
        /// <param name="value"></param>
        /// <param name="realValue"></param>
        /// <param name="category"></param>
        /// <param name="finePrints"></param>
        /// <param name="highlights"></param>
        /// <param name="termsAndCondition"></param>
        /// <param name="payCaptureStatus"></param>
        /// <param name="sideDeal"></param>
        /// <param name="metaKeywords"></param>
        /// <param name="metaDescription"></param>
        /// <param name="mainDeal"></param>
        /// <param name="expiryDate"></param>
        /// <param name="isVideo"></param>
        /// <param name="embedCode"></param>
        /// <param name="maxDealPurchase"></param>
        /// <param name="instantDeal"></param>
        /// <param name="forceCouponClosed"></param>
        /// <param name="description"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="image"></param>
        /// <param name="slideimage"></param>
        /// <param name="slideimage2"></param>
        /// <param name="slideimage3"></param>
        /// <param name="status"></param>
        /// <param name="minUserLimit"></param>
        /// <param name="maxUserLimit"></param>
        /// <param name="person"></param>
        /// <param name="phoneNo"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public string doDeals_UpdateDeal(int id, string name, string url, float value, int realValue, int category, string finePrints, string highlights, string termsAndCondition, int payCaptureStatus, int sideDeal, string metaKeywords, string metaDescription, int mainDeal, DateTime expiryDate, bool isVideo, string embedCode, int maxDealPurchase, int instantDeal, string forceCouponClosed, DateTime startDate, DateTime endDate, string description = null, string image = null, string slideimage = "", string slideimage2 = "", string slideimage3 = "", string status = null, int minUserLimit = 0, int maxUserLimit = 0, string person = null, string phoneNo = null, string address = null)
        {
            string parameters = "id=" + id.ToString();
            parameters += "name=" + name;
            parameters += "&url=" + url;
            parameters += "&description=" + description;
            parameters += "&startDate=" + startDate;
            parameters += "&endDate=" + endDate;
            parameters += "&image=" + image;
            parameters += "&slideimage=" + slideimage;
            parameters += "&slideimage2=" + slideimage2;
            parameters += "&&slideimage3=" + slideimage3;
            parameters += "&value=" + value;
            parameters += "&status=" + status;
            parameters += "&minUserLimit=" + minUserLimit;
            parameters += "&maxUserLimit=" + maxUserLimit;
            parameters += "&realValue=" + realValue;
            parameters += "&category=" + category;
            parameters += "&person=" + person;
            parameters += "&phoneNo=" + phoneNo;
            parameters += "&address=" + address;
            parameters += "&finePrints=" + finePrints;
            parameters += "&highlights=" + highlights;
            parameters += "&termsAndCondition=" + termsAndCondition;
            parameters += "&payCaptureStatus=" + payCaptureStatus;
            parameters += "&sideDeal=" + sideDeal;
            parameters += "&metaKeywords=" + metaKeywords;
            parameters += "&metaDescription=" + metaDescription;
            parameters += "&mainDeal=" + mainDeal;
            parameters += "&expiryDate=" + expiryDate;
            parameters += "&isVideo=" + isVideo;
            parameters += "&embedCode=" + embedCode;
            parameters += "&maxDealPurchase=" + maxDealPurchase;
            parameters += "&instantDeal=" + instantDeal;
            parameters += "&forceCouponClosed=" + forceCouponClosed;

            parameters = "";
            this._method = "doDeals_UpdateDeal";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Enable an existent deal
        /// </summary>
        /// <param name="id">Deal identifier</param>
        /// <returns></returns>
        public string doDeals_Deal_Enable(int id)
        {
            //coupon_status = D -> disabled
            //coupon_status = A -> enabled
            //coupon_status = C -> closed
            //coupon_status = W -> wait
            //coupon_status = S -> save
            //coupon_status = E -> expired
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_Deal_Enable";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Disable an existent deal
        /// </summary>
        /// <param name="id">Deal identifier</param>
        /// <returns></returns>
        public string doDeals_Deal_Disable(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_Deal_Disable";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete an existent deal
        /// </summary>
        /// <param name="id">Deal identifier to delete</param>
        /// <returns></returns>
        public string doDeals_Deal_Delete(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_Deal_Delete";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get the user deals
        /// </summary>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <param name="status"></param>
        /// <param name="initDate"></param>
        /// <param name="endDate"></param>
        /// <param name="search"></param>
        /// <returns></returns>
        public string doDeals_GetDeals(int init, int end, string status, string initDate, string endDate, string search)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            parameters += "&status=" + status;
            parameters += "&initDate=" + initDate;
            parameters += "&endDate=" + endDate;
            parameters += "&search=" + search;
            this._method = "doDeals_GetDeals";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get the counter of deals
        /// </summary>
        /// <param name="status"></param>
        /// <param name="initDate"></param>
        /// <param name="endDate"></param>
        /// <param name="search"></param>
        /// <returns></returns>
        public string doDeals_GetNumDeals(string status, string initDate, string endDate, string search)
        {
            string parameters = "status=" + status;
            parameters += "&initDate=" + initDate;
            parameters += "&endDate=" + endDate;
            parameters += "&search=" + search;
            this._method = "doDeals_GetNumDeals";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="transactionStatus"></param>
        /// <param name="code"></param>
        /// <param name="user"></param>
        /// <param name="initDate"></param>
        /// <param name="endDate"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doDeals_GetTransactions(int id, string transactionStatus, string code, string user, string initDate, string endDate, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&transactionStatus=" + transactionStatus;
            parameters += "&code=" + code;
            parameters += "&user=" + user;
            parameters += "&initDate=" + initDate;
            parameters += "&endDate=" + endDate;
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doDeals_GetTransactions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="transactionStatus"></param>
        /// <param name="code"></param>
        /// <param name="user"></param>
        /// <param name="initDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public string doDeals_GetNumTransactions(int id, string transactionStatus, string code, string user, string initDate, string endDate)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&transactionStatus=" + transactionStatus;
            parameters += "&code=" + code;
            parameters += "&user=" + user;
            parameters += "&initDate=" + initDate;
            parameters += "&endDate=" + endDate;
            this._method = "doDeals_GetNumTransactions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doDeals_GetCouponCategories()
        {
            string parameters = "";
            this._method = "doDeals_GetCouponCategories";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="shopid"></param>
        /// <returns></returns>
        public string doDeals_CheckShopCoupon(int id, int shopid)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&shopid=" + shopid.ToString();
            this._method = "doDeals_CheckShopCoupon";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doDeals_ValidateCoupon(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_ValidateCoupon";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doDeals_ConfirmCoupon(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_ConfirmCoupon";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doDeals_GetShopAccount()
        {
            string parameters = "";
            this._method = "doDeals_GetShopAccount";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doDeals_GetSmtpData()
        {
            string parameters = "";
            this._method = "doDeals_GetSmtpData";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doDeals_GetShopBalance()
        {
            string parameters = "";
            this._method = "doDeals_GetShopBalance";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="realvalue"></param>
        /// <param name="dealvalue"></param>
        /// <returns></returns>
        public string doDeals_GetDiscountValue(string realvalue, string dealvalue)
        {
            string parameters = "realvalue=" + realvalue;
            parameters += "&dealvalue=" + dealvalue;
            this._method = "doDeals_GetDiscountValue";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doDeals_GetContract(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_GetContract";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doDeals_DeleteDealContract(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_DeleteDealContract";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doDeals_DealsResumeStats()
        {
            string parameters = "";
            this._method = "doDeals_DealsResumeStats";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doDeals_CouponsSoldStats(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doDeals_CouponsSoldStats";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doDeals_DealsStats(int id, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doDeals_DealsStats";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doDeals_ManageDealsStats(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doDeals_DealsStats";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doDeals_GetShop(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_GetShop";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doDeals_GetMerchantCode()
        {
            string parameters = "";
            this._method = "doDeals_GetMerchantCode";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public string doDeals_UpdateMerchantCode(string code)
        {
            string parameters = "code=" + code;
            this._method = "doDeals_UpdateMerchantCode";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doDeals_GetShopData(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doDeals_GetShopData";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="accountid"></param>
        /// <param name="username"></param>
        /// <param name="firstname"></param>
        /// <param name="lastname"></param>
        /// <param name="email"></param>
        /// <param name="mobile"></param>
        /// <param name="shopname"></param>
        /// <param name="address"></param>
        /// <param name="city"></param>
        /// <param name="status"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="createdby"></param>
        /// <param name="url"></param>
        /// <param name="cp"></param>
        /// <param name="cif"></param>
        /// <param name="alias"></param>
        /// <returns></returns>
        public string doDeals_NewShop(int accountid, string username, string firstname, string lastname, string email, string mobile, string shopname, string address, string city, string url, int cp, string cif, string alias, string status = "A", string latitude = "", string longitude = "", int createdby = 1)
        {

            string parameters = "accountid=" + accountid.ToString();
            parameters += "&username=" + username;
            parameters += "&firstname=" + firstname;
            parameters += "&lastname=" + lastname;
            parameters += "&email=" + email;
            parameters += "&mobile=" + mobile;
            parameters += "&shopname=" + shopname;
            parameters += "&address=" + address;
            parameters += "&city=" + city;
            parameters += "&status=" + status;
            parameters += "&latitude=" + latitude;
            parameters += "&longitude=" + longitude;
            parameters += "&createdby=" + createdby;
            parameters += "&url=" + url;
            parameters += "&cp=" + cp;
            parameters += "&cif=" + cif;
            parameters += "&alias=" + alias;

            this._method = "doDeals_NewShop";
            return this.Call_Mandoo_Api_V1(parameters);

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="accountid"></param>
        /// <param name="username"></param>
        /// <param name="firstname"></param>
        /// <param name="lastname"></param>
        /// <param name="email"></param>
        /// <param name="mobile"></param>
        /// <param name="shopname"></param>
        /// <param name="address"></param>
        /// <param name="city"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="url"></param>
        /// <param name="cp"></param>
        /// <param name="cif"></param>
        /// <param name="alias"></param>
        /// <returns></returns>
        public string doDeals_UpdateShop(int accountid, string username, string firstname, string lastname, string email, string mobile, string shopname, string address, string city, string latitude, string longitude, string url, string cp, string cif, string alias)
        {
            string parameters = "accountid=" + accountid.ToString();
            parameters += "&username=" + username;
            parameters += "&firstname=" + firstname;
            parameters += "&lastname=" + lastname;
            parameters += "&email=" + email;
            parameters += "&mobile=" + mobile;
            parameters += "&shopname=" + shopname;
            parameters += "&address=" + address;
            parameters += "&city=" + city;
            parameters += "&latitude=" + latitude;
            parameters += "&longitude=" + longitude;
            parameters += "&url=" + url;
            parameters += "&cp=" + cp;
            parameters += "&cif=" + cif;
            parameters += "&alias=" + alias;
            this._method = "doDeals_UpdateShop";
            return this.Call_Mandoo_Api_V1(parameters);
        }

        #endregion

        #region doBot
        /***************************************************************************/
        /*								doBot									 */
        /***************************************************************************/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="enabled"></param>
        /// <param name="productId"></param>
        /// <param name="url"></param>
        /// <param name="image"></param>
        /// <param name="linked"></param>
        /// <param name="shared"></param>
        /// <returns></returns>
        public string doBot_NewService(string name, string description, bool enabled, int productId, string url, string image, int linked = 0, int shared = 0)
        {
            string parameters = "name=" + name;
            parameters += "description=" + description;
            parameters += "enabled=" + enabled;
            parameters += "productId=" + productId.ToString();
            parameters += "url=" + url;
            parameters += "image=" + image;
            parameters += "linked=" + linked;
            parameters += "shared=" + shared;
            this._method = "doBot_NewService";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="enabled"></param>
        /// <param name="productId"></param>
        /// <param name="url"></param>
        /// <param name="image"></param>
        /// <param name="linked"></param>
        /// <param name="shared"></param>
        /// <returns></returns>
        public string doBot_UpdateService(int id, string name, string description, bool enabled, int productId, string url, string image, int linked = 0, int shared = 0)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&name=" + name;
            parameters += "&description=" + description;
            parameters += "&enabled=" + enabled.ToString();
            parameters += "&productId=" + productId.ToString();
            parameters += "&url=" + url;
            parameters += "&image=" + image;
            parameters += "&linked=" + linked;
            parameters += "&shared=" + shared;
            this._method = "doBot_UpdateService";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_DeleteService(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_DeleteService";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="privatebot"></param>
        /// <returns></returns>
        public string doBot_GetNumServices(bool privatebot)
        {
            string parameters = "private=" + privatebot.ToString();
            this._method = "doBot_GetNumServices";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="enabled"></param>
        /// <param name="privatebot"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetServices(bool enabled, bool privatebot, int init, int end)
        {
            string parameters = "enabled=" + enabled.ToString();
            parameters += "&private=" + privatebot.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetServices";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="privatebot"></param>
        /// <returns></returns>
        public string doBot_GetService(int id, bool privatebot)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&private=" + privatebot.ToString();
            this._method = "doBot_GetService";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="privatebot"></param>
        /// <returns></returns>
        public string doBot_GetNumServicesConditions(bool privatebot)
        {
            string parameters = "private=" + privatebot.ToString();
            this._method = "doBot_GetNumServicesConditions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="privatebot"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetServicesWithConditions(bool privatebot, int init, int end)
        {
            string parameters = "private=" + privatebot.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetServicesWithConditions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="privatebot"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_GetNumServicesActions(bool privatebot, int id)
        {
            string parameters = "private=" + privatebot.ToString();
            parameters += "&id=" + id.ToString();
            this._method = "doBot_GetNumServicesActions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="privatebot"></param>
        /// <param name="id"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetServicesWithActions(bool privatebot, int id, int init, int end)
        {
            string parameters = "private=" + privatebot.ToString();
            parameters += "&id=" + id.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetServicesWithActions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_GetServicesByAccount(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_GetServicesByAccount";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public string doBot_EnableServiceAccount(int id, int value)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&value=" + value.ToString();
            this._method = "doBot_EnableServiceAccount";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_DeleteServiceAccount(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_DeleteServiceAccount";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="serviceid"></param>
        /// <param name="privatebot"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetConditions(int id, int serviceid, bool privatebot, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&serviceid=" + serviceid.ToString();
            parameters += "&private=" + privatebot.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetConditions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="serviceid"></param>
        /// <param name="privatebot"></param>
        /// <param name="conditionid"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetActions(int id, int serviceid, bool privatebot, int conditionid, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&serviceid=" + serviceid.ToString();
            parameters += "&private=" + privatebot.ToString();
            parameters += "&conditionid=" + conditionid.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetActions";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="conditionid"></param>
        /// <param name="actionid"></param>
        /// <param name="enabled"></param>
        /// <param name="conditionAttrs"></param>
        /// <param name="actionAttrs"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public string doBot_UpdateTrigger(int id, int conditionid, int actionid, bool enabled, string conditionAttrs, string actionAttrs, string description)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&conditionid=" + conditionid.ToString();
            parameters += "&actionid=" + actionid.ToString();
            parameters += "&enabled=" + enabled.ToString();
            parameters += "&conditionAttrs=" + conditionAttrs;
            parameters += "&actionAttrs=" + actionAttrs;
            parameters += "&description=" + description;
            this._method = "doBot_UpdateTrigger";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_DeleteTrigger(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_DeleteTrigger";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetNumTriggers(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetNumTriggers";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetTriggers(int id, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetTriggers";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_EnableTrigger(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_EnableTrigger";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_DisableTrigger(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_EnableTrigger";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userid"></param>
        /// <param name="accountid"></param>
        /// <returns></returns>
        public string doBot_UserHasTrigger(int id, int userid, int accountid)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&userid=" + userid.ToString();
            parameters += "&accountid=" + accountid.ToString();
            this._method = "doBot_UserHasTrigger";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_QueueTrigger(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_QueueTrigger";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="limit"></param>
        /// <returns></returns>
        public string doBot_PopTrigger(int limit = 100)
        {
            string parameters = "limit=" + limit;
            this._method = "doBot_PopTrigger";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public string doBot_CreateTriggerLog(int id, bool status, string log)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&status=" + status.ToString();
            parameters += "&log=" + log;
            this._method = "doBot_CreateTriggerLog";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doBot_CheckTriggerTimer(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doBot_CheckTriggerTimer";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public string doBot_GetNumLogsByAccount(int id, int init, int end, string status)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&init=" + init;
            parameters += "&end=" + end;
            parameters += "&status=" + status;
            this._method = "doBot_GetNumLogsByAccount";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="initDate"></param>
        /// <param name="endDate"></param>
        /// <param name="status"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetLogsByAccount(int id, string initDate, string endDate, string status, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&initDate=" + initDate;
            parameters += "&endDate=" + endDate;
            parameters += "&status=" + status;
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doBot_GetNumServices";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetTriggerLogsByDateStatistics(int id, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters = "&init=" + init.ToString();
            parameters = "&end=" + end.ToString();
            this._method = "doBot_GetNumServices";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doBot_GetMonthlyLogsByDateStatistics(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters = "&end=" + end.ToString();
            this._method = "doBot_GetNumServices";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doBot_GetTriggersResumeStatistics()
        {
            string parameters = "";
            this._method = "doBot_GetTriggersResumeStatistics";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        #endregion

        #region doAccount

        /***************************************************************************/
        /*								doAccount							 	   */
        /***************************************************************************/
        /// <summary>
        /// Get user timezone
        /// </summary>
        /// <param name="id">User identifier</param>
        /// <returns>Returns string with timezone. Default value: '190|GMT|0'</returns>
        public string doAccount_GetTimezoneUser(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doAccount_GetTimezoneUser";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetNumProducts()
        {
            string parameters = "";
            this._method = "doAccount_GetNumProducts";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get number of products contracted
        /// </summary>
        /// <param name="id">Account identifier</param>
        /// <returns></returns>
        public string doAccount_GetNumProductsContracted(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doAccount_GetNumProductsContracted";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doAccount_GetProductsContracted(int id, int init, int end)
        {
            string parameters = "id=" + id.ToString();
            parameters += "&init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doAccount_GetProductsContracted";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetAccountEmails()
        {
            string parameters = "";
            this._method = "doAccount_GetAccountEmails";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetTimezone()
        {
            string parameters = "";
            this._method = "doAccount_GetTimezone";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetCreatedTime()
        {
            string parameters = "";
            this._method = "doAccount_GetCreatedTime";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetWebsite()
        {
            string parameters = "";
            this._method = "doAccount_GetWebsite";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doAccount_LastAccesses(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doAccount_LastAccesses";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetNumInvoices()
        {
            string parameters = "";
            this._method = "doAccount_GetNumInvoices";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="init"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public string doAccount_GetProducts(int init, int end)
        {
            string parameters = "init=" + init.ToString();
            parameters += "&end=" + end.ToString();
            this._method = "doAccount_GetProducts";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id">Product identifier</param>
        /// <returns></returns>
        public string doAccount_GetPack(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doAccount_GetPack";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="link"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public string doAccount_UpdateAccesses(string link, string title)
        {
            string parameters = "link=" + link;
            parameters += "&title=" + title;
            this._method = "doAccount_UpdateAccesses";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetAccountCreatedTime()
        {
            string parameters = "";
            this._method = "doAccount_GetAccountCreatedTime";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doAccount_GetProduct(int id)
        {
            string parameters = "id=" + id.ToString();
            this._method = "doAccount_GetProduct";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetAccounts()
        {
            string parameters = "";
            this._method = "doAccount_GetAccounts";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doAccount_GetAccountUsers()
        {
            string parameters = "";
            this._method = "doAccount_GetAccountUsers";
            return this.Call_Mandoo_Api_V1(parameters);
        }


        public string doAccount_Login(string user, string password)
        {
            string parameters = "";
            parameters = "user=" + user;
            parameters += "&pass=" + password;
            this._method = "doAccount_Login";
            return this.Call_Mandoo_Api_V1(parameters);
        }


        public string doAccount_Register(string email, string password, string company, string phone, string name, string surnames, string language, string accountparentid)
        {
            string parameters = "";
            parameters = "email=" + email;
            parameters += "&password=" + password;
            parameters += "&company=" + company;
            parameters += "&phone=" + phone;
            parameters += "&name=" + name;
            parameters += "&surnames=" + surnames;
            parameters += "&language=" + language;
            parameters += "&accountparentid=" + accountparentid;

            this._method = "doAccount_Register";
            return this.Call_Mandoo_Api_V1(parameters);
        }


        public string doAccount_RememberPassword(string email)
        {
            string parameters = "";
            parameters = "email=" + email;

            this._method = "doAccount_RememberPassword";
            return this.Call_Mandoo_Api_V1(parameters);
        }

        #endregion

        #region doSMS

        /***************************************************************************/
        /*								doSMS	    						 	   */
        /***************************************************************************/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public string doSms_Groups(string ids)
        {
            string parameters = "ids=0";
            if (ids != null && ids != "" && ids != "0")
            {
                parameters = "ids=" + ids;
            }
            this._method = "doSms_Groups";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public string doSms_Group_Subscribers(string ids)
        {
            string parameters = "ids=0";
            if (ids != null && ids != "" && ids != "0")
            {
                parameters = "ids=" + ids;
            }
            this._method = "doSms_Group_Subscribers";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Add a new group
        /// </summary>
        /// <param name="title">Name of the new group</param>
        /// <returns></returns>
        public string doSms_AddGroup(string title)
        {
            string parameters = "title=";

            if (title != null && title != "")
            {
                parameters = "title=" + title;
            }
            this._method = "doSms_AddGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Change the values ​​of an existing group
        /// </summary>
        /// <param name="id">Group identifier</param>
        /// <param name="title">Name of the group to update</param>
        /// <returns></returns>
        public string doSms_UpdateGroup(int id, string title)
        {
            string parameters = "title=";

            if (title != null && title != "")
            {
                parameters = "title=" + title;
            }
            if (id > 0)
            {
                parameters += "&id=" + id.ToString();
            }
            this._method = "doSms_UpdateGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete a existing group
        /// </summary>
        /// <param name="id">Group identifier to delete</param>
        /// <returns></returns>
        public string doSms_DeleteGroup(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            this._method = "doSms_DeleteGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Add a new subscriber
        /// </summary>
        /// <param name="mobile">Mobile number for new subscriber</param>
        /// <returns></returns>
        public string doSms_AddSubscriber(string mobile)
        {
            string parameters = "";

            if (mobile != null && mobile != "")
            {
                parameters = "mobile=" + mobile;
            }
            this._method = "doSms_AddSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Check if is subscriber
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public string doSms_IsSubscriber(string mobile)
        {
            string parameters = "";

            if (mobile != null && mobile != "")
            {
                parameters = "mobile=" + mobile;
            }
            this._method = "doSms_IsSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public string doSms_GetSubscriber(int id, string mobile)
        {
            string parameters = "1=1";

            if (id > 0)
            {
                parameters += "&id=" + id.ToString();
            }
            if (mobile != null && mobile != "")
            {
                parameters += "&mobile=" + mobile;
            }
            this._method = "doSms_GetSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doSms_DeleteSubscriber(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            this._method = "doSms_DeleteSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public string doSms_DeleteSubscriberMobile(string mobile)
        {
            string parameters = "";

            if (mobile != null && mobile != "")
            {
                parameters = "mobile=" + mobile;
            }
            this._method = "doSms_DeleteSubscriberMobile";

            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="users"></param>
        /// <returns></returns>
        public string doSms_AddSubscriberToGroup(int id, string users)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            if (users != null && users != "")
            {
                parameters += "&users=" + users;
            }
            this._method = "doSms_AddSubscriberToGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="users"></param>
        /// <returns></returns>
        public string doSms_RemoveSubscriberToGroup(int id, string users)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            if (users != null && users != "")
            {
                parameters += "&users=" + users;
            }
            this._method = "doSms_RemoveSubscriberToGroup";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="campaignId"></param>
        /// <param name="groups"></param>
        /// <param name="message"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public string doSms_SendSMS(int campaignId, string groups, string message, string description)
        {
            string parameters = "";

            if (campaignId > 0)
            {
                parameters = "campaignId=" + campaignId.ToString();
            }
            if (groups != null && groups != "")
            {
                parameters += "&groups=" + groups;
            }
            if (message != null && message != "")
            {
                parameters += "&message=" + message;
            }
            if (description != null && description != "")
            {
                parameters += "&description=" + description;
            }


            this._method = "doSms_SendSMS";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="campaignId"></param>
        /// <param name="subscriber"></param>
        /// <param name="message"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public string doSms_SendSMSToSubscriber(int campaignId, string subscriber, string message, string description)
        {
            string parameters = "";

            if (campaignId > 0)
            {
                parameters = "campaignId=" + campaignId.ToString();
            }
            if (subscriber != null && subscriber != "")
            {
                parameters += "&subscriber=" + subscriber;
            }
            if (message != null && message != "")
            {
                parameters += "&message=" + message;
            }
            if (description != null && description != "")
            {
                parameters += "&description=" + description;
            }

            this._method = "doSms_SendSMSToSubscriber";
            return this.Call_Mandoo_Api_V1(parameters);
        }

        /// <summary>
        /// Send an SMS to the phones
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public string doSms_SendSMS_Phones(int campaignId, string[] phones, string message, string description, DateTime sendDate)
        {
            string parameters = "campaignId=";
            if (campaignId > 0)
            {
                parameters += campaignId.ToString();
            }
            if (phones.Length > 0)
            {
                parameters += "&phones=" + String.Join(";", phones);
            }
            if (message != null && message != "")
            {
                parameters += "&message=" + message;
            }
            if (description != null && description != "")
            {
                parameters += "&description=" + description;
            }
            if (sendDate != null)
            {
                parameters += "&sendDate=" + sendDate;
            }

            this._method = "doSms_SendSMS_Phones";
            return this.Call_Mandoo_Api_V1(parameters);
        }

        /// <summary>
        /// Add a new campaign
        /// </summary>
        /// <param name="name">Name of the new campaign</param>
        /// <returns></returns>
        public string doSms_AddCampaign(string name)
        {
            string parameters = "";

            if (name != null && name != "")
            {
                parameters = "name=" + name;
            }
            this._method = "doSms_AddCampaign";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Delete a campaign with a specific id
        /// </summary>
        /// <param name="id">Campaign id to be deleted</param>
        /// <returns></returns>
        public string doSms_DeleteCampaign(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            this._method = "doSms_DeleteCampaign";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// Get a campaign with specific id
        /// </summary>
        /// <param name="id">Campaign identificator</param>
        /// <returns></returns>
        public string doSms_GetCampaign(int id)
        {
            string parameters = "";

            if (id > 0)
            {
                parameters = "id=" + id.ToString();
            }
            this._method = "doSms_GetCampaign";
            return this.Call_Mandoo_Api_V1(parameters);
        }

        /// <summary>
        /// Get account SMS credits
        /// </summary>
        /// <returns></returns>
        public string doSms_GetCredits()
        {
            string parameters = "";
            this._method = "doSms_GetCredits";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string doSms_GetTemplate(int id)
        {
            string parameters = "";
            if (id > 0)
            {
                parameters += "id=" + id;
            }
            this._method = "doSms_GetTemplate";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public string doSms_GetTemplates(int category)
        {
            string parameters = "";
            if (category > 0)
            {
                parameters += "category=" + category;
            }
            this._method = "doSms_GetTemplates";
            return this.Call_Mandoo_Api_V1(parameters);
        }
        #endregion
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string doSms_GetCategoryTemplates()
        {
            string parameters = "";
            this._method = "doSms_GetCategoryTemplates";
            return this.Call_Mandoo_Api_V1(parameters);
        }


        #region Private

        private string Call_Mandoo_Api_V1(string _params)
        {
            Task<string> result = AsyncCall_Mandoo_Api_V1(_params);
            return result.Result;
        }

        private async Task<string> AsyncCall_Mandoo_Api_V1(string _params)
        {
            this._output = null;
            string sign = this._clientId + this._responseFormat + this._method + this._clientSecret;
            string parameters = "key=" + this._clientSecret + "&output=" + this._responseFormat;
            if (_params != "")
            {
                parameters += "&" + _params;
            }

            HashAlgorithmProvider provider = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1);
            IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(sign, BinaryStringEncoding.Utf8);
            IBuffer hash = provider.HashData(buffer);
            string signSha1 = CryptographicBuffer.EncodeToHexString(hash);

            parameters += "&sign=" + signSha1.Replace("-", "").ToLower();

            string curlUrl = "";

            if (this._httpMethod.ToLower() == "get")
            {
                curlUrl = this._apiUrl + this._method + "?" + parameters;
            }
            if (this._httpMethod.ToLower() == "post")
            {
                curlUrl = this._apiUrl + this._method;
            }
            HttpClient httpClient = new HttpClient();
            HttpRequestMessage httpRequestMessage;
            HttpResponseMessage httpResponseMessage = null;

            if (this._httpMethod.ToLower() == "post")
            {
                httpRequestMessage = new HttpRequestMessage(System.Net.Http.HttpMethod.Post, curlUrl);
                httpRequestMessage.Content = new StreamContent(new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(parameters)));
                httpRequestMessage.Content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            }
            else
            {
                httpRequestMessage = new HttpRequestMessage(System.Net.Http.HttpMethod.Get, curlUrl);
            }
            try
            {
               httpResponseMessage = await httpClient.SendAsync(httpRequestMessage)
                                                        .ConfigureAwait(continueOnCapturedContext: false);
               httpResponseMessage.EnsureSuccessStatusCode();
               this._output = await httpResponseMessage.Content.ReadAsStringAsync();
            }
            catch //(HttpRequestException hre)
            {
               return "";
            }
            switch (this._responseFormat)
            {
                case "json":
                    if (this._includeOutHeader)
                    {
                        httpResponseMessage.Headers.Add("Content-type","application/json");

                    }
                    return this._output;
                case "xml":
                    if (this._includeOutHeader)
                    {
                        httpResponseMessage.Headers.Add("Content-type","text/xml");
                    }
                    return this._output;
                case "serialized":
                    if (this._includeOutHeader)
                    {
                        httpResponseMessage.Headers.Add("Content-type","text/plain");
                    }
                    return this._output;
                case "return":
                    return this._output;
            }
            return "";
        }
        #endregion
    }
}
